<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%
    String path = request.getContextPath();
%>
<html>
<head>

    <title>Document</title>
    <jsp:include page="WEB-INF/jsp/common/css_js.jsp"/>
    <style>
        .body {
            background: url('<%=path%>/img/bg.jpg');
            background-repeat: no-repeat;
            background-size: 100% auto;

        }
    </style>

</head>
<body class="body">

<div id="lg1">
    <button type="button" class="btn btn-outline-secondary btn-sm" onclick="register()"><font
            color="#f0f8ff">注册新用户</font></button>
</div>
<div id="lg">
    <button type="button" class="btn btn-outline-secondary btn-sm" onclick="admLogin()"><font
            color="#f0f8ff">管理员登录</font></button>
</div>

<div id="login-box">
    <h3>用户登录</h3>
    <br>
    <div class="form">
        <div class="item">
            <div class="form-group" style="width: 200px; margin: 0 auto;">
                <input type="text" class="form-control" id="exampleInputName1" placeholder="name"><br>
                <input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
            </div>
        </div>
    </div>
    <div class="layui-btn-container">
        <button type="button" class="layui-btn layui-btn-primary layui-btn-radius" onclick="customerLogin()">enter</button>
    </div>
</div>
<div>
    <br><br><br><br><br><br>
    <p align="center" >Copyright 2021-2022 @HQYJ </p>
</div>
<script>
    function register() {
        location.href="customer/registerPage"
    }

    function admLogin() {
        location.href="adm_Login.jsp"
    }

    function customerLogin() {
        $.ajax({
            url:"customer/login",
            method:"post",
            data:{
                username:$("#exampleInputName1").val(),
                password:$("#exampleInputPassword1").val(),
            },
            dataType: "json",
            success:function (data) {
                if (data['code']==0){
                    location.href="customer/home";
                }else {
                    alert(data['message']);
                }
            },error:function (e) {
                console.log(e);
            }
        })
    }
</script>

</body>
</html>
